package com.huanshi.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huanshi.entity.PmsCategory;
import com.huanshi.mapper.PmsCategoryMapper;
import com.huanshi.service.PmsCategoryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 商品类目，Service业务层处理
 * 
 * @author 幻世
 * @date 2023-07-02
 */
@Service
public class PmsCategoryServiceImpl extends ServiceImpl<PmsCategoryMapper, PmsCategory> implements PmsCategoryService {
    @Resource
    private PmsCategoryMapper pmsCategoryMapper;

    @Override
    public List<PmsCategory> selectParentCategory() {

        return pmsCategoryMapper.selectList(
                new LambdaQueryWrapper<PmsCategory>()
                        .eq(PmsCategory::getIsParent, 1)
        );
    }

    @Override
    public List<PmsCategory> getChildrenById(Long pid) {
        return pmsCategoryMapper.selectList(
                new LambdaQueryWrapper<PmsCategory>()
                        .eq(PmsCategory::getParentId, pid)
        );
    }
}
